/**
 * @file graphics.h
 * @brief drawing objects
 */

#include <graphics.h>
#include <allegro5/allegro_primitives.h>
/* Drawing objects is here */

void asteroid_draw(Asteroid *a) {
  ALLEGRO_TRANSFORM transform;
  al_build_transform(&transform, a->sx, a->sy, a->scale, a->scale, a->twist);
  al_use_transform(&transform);
  al_draw_line(-20, 20, -25, 5, a->color, 2.0f);
  al_draw_line(-25, 5, -25, -10, a->color, 2.0f);
  al_draw_line(-25, -10, -5, -10, a->color, 2.0f);
  al_draw_line(-5, -10, -10, -20, a->color, 2.0f);
  al_draw_line(-10, -20, 5, -20, a->color, 2.0f);
  al_draw_line(5, -20, 5, -20, a->color, 2.0f);
  al_draw_line(20, -10, 20, -5, a->color, 2.0f);
  al_draw_line(20, -5, 0, 0, a->color, 2.0f);
  al_draw_line(0, 0, 20, 10, a->color, 2.0f);
  al_draw_line(20, 10, 10, 20, a->color, 2.0f);
  al_draw_line(10, 20, 0, 15, a->color, 2.0f);
  al_draw_line(0, 15, -20, 20, a->color, 2.0f);
  al_draw_line(5, -20, 20, -20, a->color, 2.0f);
  al_draw_line(20, -20, 20, -5, a->color, 2.0f);
}

void ship_draw(Spaceship *s) {
  ALLEGRO_TRANSFORM transform;
  al_build_transform(&transform, s->sx, s->sy, SHIP_SCALE, SHIP_SCALE,
      s->twist);
  al_use_transform(&transform);
  al_draw_line(-8, 9, 0, -11, s->color, 3.0f);
  al_draw_line(0, -11, 8, 9, s->color, 3.0f);
  al_draw_line(-6, 4, -1, 4, s->color, 3.0f);
  al_draw_line(6, 4, 1, 4, s->color, 3.0f);
}
